package com.eunion.web.common.vo.jpa;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang3.builder.ReflectionToStringBuilder;

/**
 * 查询条件对象.
 * 
 * 
 * @version 2015-9-12
 */
public class SpecConVo {

    /**
     * 是否是and条件.
     */
    private boolean and = true; // and or

    /**
     * 域.
     */
    private String field;

    /**
     * 类型.
     */
    private String type;

    /**
     * 条件 > < >= <= <> != like not like not in.
     */
    private String condition;

    /**
     * 值.
     */
    private Object value;

    /**
     * 子查询条件.
     */
    private List<SpecConVo> scs = new ArrayList<SpecConVo>();

    @Override
    public String toString() {
        return ReflectionToStringBuilder.toString(this);
    }

    public SpecConVo(boolean and, String field, String type, String condition, Object value) {
        super();
        this.and = and;
        this.field = field;
        this.type = type;
        this.condition = condition;
        this.value = value;
    }

    public SpecConVo() {
    }

    /**
     * 构造器.
     * 
     * 
     * @version 2016年1月18日
     */
    public static class Builder {
        
        private boolean and = true; // and or

        private String field;

        private String type;

        private String condition;// > < >= <= <> != like not like not in

        private Object value;

        public Builder setAnd(boolean and) {
            this.and = and;
            return this;
        }

        public Builder setField(String field) {
            this.field = field;
            return this;
        }

        public Builder setType(String type) {
            this.type = type;
            return this;
        }

        public Builder setCondition(String condition) {
            this.condition = condition;
            return this;
        }

        public Builder setValue(Object value) {
            this.value = value;
            return this;
        }

        public SpecConVo build() {
            return new SpecConVo(and, field, type, condition, value);
        }
    }

    /**
     * get 是否是and条件. .
     * 
     * @return the and
     */
    public boolean isAnd() {
        return and;
    }

    /**
     * set 是否是and条件..
     * 
     * @param and
     *            the and to set
     */
    public void setAnd(boolean and) {
        this.and = and;
    }

    /**
     * get 域 .
     * 
     * @return the field
     */
    public String getField() {
        return field;
    }

    /**
     * set 域.
     * 
     * @param field
     *            the field to set
     */
    public void setField(String field) {
        this.field = field;
    }

    /**
     * get 类型. .
     * 
     * @return the type
     */
    public String getType() {
        return type;
    }

    /**
     * set 类型..
     * 
     * @param type
     *            the type to set
     */
    public void setType(String type) {
        this.type = type;
    }

    /**
     * get 条件 > < >= <= <> != like not like not in .
     * 
     * @return the condition
     */
    public String getCondition() {
        return condition;
    }

    /**
     * set 条件 > < >= <= <> != like not like not in.
     * 
     * @param condition
     *            the condition to set
     */
    public void setCondition(String condition) {
        this.condition = condition;
    }

    /**
     * get 值. .
     * 
     * @return the value
     */
    public Object getValue() {
        return value;
    }

    /**
     * set 值..
     * 
     * @param value
     *            the value to set
     */
    public void setValue(Object value) {
        this.value = value;
    }

    /**
     * get 子查询条件. .
     * 
     * @return the scs
     */
    public List<SpecConVo> getScs() {
        return scs;
    }

    /**
     * set 子查询条件..
     * 
     * @param scs
     *            the scs to set
     */
    public void setScs(List<SpecConVo> scs) {
        this.scs = scs;
    }

}
